var url='http://120.27.161.98:6655'
$(document).ready(function () {
    //图片切换
    var img=$(".floor3-pics>ul>li>img");
    img.hover(
        function(e){
            var $this=$(e.target);
            var str=$this.attr('src').replace(/1.png/g,'2.png');
            $this.attr('src',str);
        },
        function(e){
           var $this=$(e.target);
            var str=$this.attr('src').replace(/2.png/g,'1.png');
            $this.attr('src',str);
        }
    );
});
$('.submit').on('click', function () {
    if($('textarea').val()==''||$('#userphone').val()==''||$('#username').val()==''){
        $('.zzzz').show();
        $('.txt-alert').text('请完善必填信息')
    }else{
        var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
        if(pattern.test($('#userphone').val())) {
            $.ajax({
                url: url + '/api/WebPage/AddMess',
                type: 'POST',

                data: {
                    MessContent: $('textarea').val(),
                    MessPhone: $('#userphone').val(),
                    MessUserName: $('#username').val(),
                    classid: "16"
                },
                success: function (data) {
                    console.log(data);
                    if (data.code == 200) {
                        $('.zzzz').show();
                        $('.txt-alert').text('提交成功！')
                        $('textarea').val('');
                        $('#userphone').val('');
                        $('#username').val('');
                    } else {
                        $('.zzzz').show();
                        $('.txt-alert').text(data.mes)
                    }
                }
            })
        }else{
            $('.zzzz').show();
            $('.txt-alert').text('请填写正确的号码！')
        }
    }
});
$('.mis-btn').on('click',function () {
    $('.zzzz').hide()
})